

import type { Iuser } from './entity';
import request from '@/api/request'

export function userList(params: any) {
  return request({
    url: `admin/user/list`,
    method: 'get',
    params,
    loading: true
  })
}

export function userDel(data: any) {
  return request({
    url: `admin/user/delete`,
    method: 'post',
    data
  })
}
export function userinfo(userId: number) {
  return request({
    url: `/admin/user/topdetail`,
    method: 'get',
    params: { userId }
  })
}
export function infobyconditionApi(params: any) {
  return request({
    url: `/admin/user/infobycondition`,
    method: 'get',
    params
  })
}
export function integralListApi(params: any) {
  return request({
    url: '/admin/user/integral/list',
    method: 'post',
    params,
    data: { uid: params.uid }
  })
}
export function userSelect(id: number) {
  return request({
    url: `admin/user/select`,
    method: 'get'
  })
}

export function userAddup(data: any) {
  return request({
    url: `admin/user/${!data.id ? 'save' : 'update'}`,
    method: 'post',
    data
  })
}

export function userlevelList(params: any) {
  return request({
    url: `admin/system/user/level/list`,
    method: 'get',
    params,
    loading: true
  }).then(list => { return { list } })
}

export function userlevelDel(id: number) {
  return request({
    url: `admin/system/user/level/delete/${id}`,
    method: 'post',

  })
}
export function userlevelinfo(id: number) {
  return request({
    url: `admin/system/user/level/info/${id}`,
    method: 'get'
  })
}
/**
 * 会员等级 是否显示
 * @param pram
 */
export function levelUseApi(data: any) {
  return request({
    url: `/admin/system/user/level/use`,
    method: 'post',
    data
  })
}

export function userlevelAddup(data: any) {
  return request({
    url: `admin/system/user/level/${!data.id ? 'save' : 'update'}`,
    method: 'post',
    data
  })
}


export function usergroupList(params: any) {
  return request({
    url: `admin/user/group/list`,
    method: 'get',
    params,
    loading: true
  })
}

export function usergroupDel(data: any) {
  return request({
    url: `admin/user/group/delete`,
    method: 'post',
    data
  })
}
export function usergroupinfo(id: number) {
  return request({
    url: `admin/user/group/info/${id}`,
    method: 'get'
  })
}
export function usergroupSelect(id: number) {
  return request({
    url: `admin/user/group/select`,
    method: 'get'
  })
}

export function usergroupAddup(data: any) {
  return request({
    url: `admin/user/group/${!data.id ? 'save' : 'update'}`,
    method: 'post',
    data
  })
}

export function usertagList(params: any) {
  return request({
    url: `admin/user/tag/list`,
    method: 'get',
    params,
    loading: true
  })
}

export function usertagDel(data: any) {
  return request({
    url: `admin/user/tag/delete`,
    method: 'post',
    data
  })
}
export function usertaginfo(id: number) {
  return request({
    url: `admin/user/tag/info/${id}`,
    method: 'get'
  })
}
export function usertagSelect(id: number) {
  return request({
    url: `admin/user/tag/select`,
    method: 'get'
  })
}

export function usertagAddup(data: any) {
  return request({
    url: `admin/user/tag/${!data.id ? 'save' : 'update'}`,
    method: 'post',
    data
  })
}
/**
 * 会员管理 列表
 * @param pram
 */
export function adminList(params: any) {
  return request({
    url: `/admin/user/list`,
    method: 'get',
    params,
    loading: true
  })
}
export function updateSpreadApi(data: any) {
  return request({
    url: `/admin/user/update/spread`,
    method: 'post',
    data
  })
}

/**
 * 会员管理 批量设置分组
 * @param pram
 */
export function groupPiApi(params: any) {
  return request({
    url: `/admin/user/group`,
    method: 'post',
    params
  })
}

/**
 * 会员管理 批量设置标签
 * @param pram
 */
export function tagPiApi(params: any) {
  return request({
    url: `/admin/user/tag`,
    method: 'post',
    params
  })
}
/**
 * 会员管理 积分余额
 * @param pram
 */
export function foundsApi(params: any) {
  return request({
    url: `/admin/user/operate/founds`,
    method: 'get',
    params
  })
}
/**
 * 会员管理等级 修改
 * @param pram
 */
export function userLevelUpdateApi(data) {
  return request({
    url: `/admin/user/update/level`,
    method: 'post',
    data
  })
}
/**
 * @description 推广人 -- 清除上级推广人
 */
export function spreadClearApi(id) {
  return request({
    url: `/admin/store/retail/spread/clean/${id}`,
    method: 'get'
  })
}